<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加商品</title>
    <!-- 引入axios -->
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
    <!-- 引入Vue -->
    <script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>

</head>

<body>
    <div>
        <center>
            <h1>添加商品</h1>
            <input type="text" v-model="p.title" placeholder="标题">
            <input type="text" v-model="p.price" placeholder="价格">
            <input type="text" v-model="p.num" placeholder="库存">
            <input type="button" value="添加" @click="add()">
        </center>
    </div>

    <script>
        let v = new Vue({
            el: "body>div",
            data: {
                p: {
                    title: "",
                    price: "",
                    num: ""
                }
            },
            methods: {
                add() {
                    axios.post("/add", v.p).then(function (response) {
                        alert("添加成功!");
                    })
                }
            }
        })
    </script>
</body>

</html>